import request from '../../utils/request';

// 文章管理相关 API

// 更新文章
export const updateArticle = (data: any) => {
    return request({
        url: '/content/api/article',
        method: 'put',
        data
    });
};

// 创建文章
export const createArticle = (data: any) => {
    return request({
        url: '/content/api/article',
        method: 'post',
        data
    });
};

// 查询文章详情
export const getArticleDetail = (id: string) => {
    return request({
        url: `/content/api/article/${id}`,
        method: 'get'
    });
};

// 删除文章
export const deleteArticle = (id: string) => {
    return request({
        url: `/content/api/article/${id}`,
        method: 'delete'
    });
};

// 下线文章
export const offlineArticle = (id: string) => {
    return request({
        url: `/content/api/article/${id}/offline`,
        method: 'post'
    });
};

// 发布文章
export const publishArticle = (id: string) => {
    return request({
        url: `/content/api/article/${id}/publish`,
        method: 'post'
    });
};

// 设置文章推荐状态
export const setArticleRecommendStatus = (id: string, data: any) => {
    return request({
        url: `/content/api/article/${id}/recommend`,
        method: 'put',
        data
    });
};

// 增加文章阅读量
export const increaseArticleReadCount = (id: string) => {
    return request({
        url: `/content/api/article/${id}/view`,
        method: 'post'
    });
};

// 审核文章
export const auditArticle = (data: any) => {
    return request({
        url: '/content/api/article/audit',
        method: 'post',
        data
    });
};

// 查询文章列表
export const getArticleList = (params: any) => {
    return request({
        url: '/content/api/article/list',
        method: 'get',
        params
    });
};

// 分页查询文章列表
export const getArticlePage = (params: any) => {
    return request({
        url: '/content/api/article/page',
        method: 'get',
        params
    });
};

// 搜索文章
export const searchArticle = (params: any) => {
    return request({
        url: '/content/api/article/search',
        method: 'get',
        params
    });
};
